<template>
  <div :class="['chat-sidebar', { 'sidebar-hidden': !showSidebar }]">
    <div class="sidebar-header">
      <h3>题目</h3>
      <el-button type="success" @click="">新建文件</el-button>
    </div>
    
    <div class="chat-list">
      <el-scrollbar style="background-color: var(--primary-color);">
        <h1>hhh</h1>
      </el-scrollbar>
    </div>
    
    <div class="sidebar-footer">
      <el-button
          @click="handleSetting">
        <el-icon><Setting /></el-icon>
        <span>Btn1</span>
      </el-button>
      <el-button
          @click="handleModelManager">
        <el-icon><Setting /></el-icon>
        <span>Btn2</span>
      </el-button>
    </div>

    <div class="sidebar-toggle" @click="$emit('toggle-sidebar')">
      <el-icon><ArrowLeft :class="{ 'rotated': !showSidebar }" /></el-icon>
    </div>
  </div>
</template>

<script setup>
import { ArrowLeft } from '@element-plus/icons-vue'

defineProps({
  showSidebar: {
    type: Boolean,
    default: true
  }
})

function handleSetting(){

}
function handleModelManager(){

}
</script>

<style scoped>
.chat-sidebar {
  position: fixed;
  left: 0;
  top: 5px;
  bottom: 0;
  width: 300px;
  background: var(--el-bg-color);
  border-right: 1px solid var(--el-border-color-lighter);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 100;
}

.sidebar-hidden {
  transform: translateX(-300px);
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--el-border-color-lighter);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h3 {
  margin: 0;
  font-size: 16px;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.chat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s;
}


.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--el-border-color-lighter);
}


.manage-btn .el-icon {
  margin-right: 4px;
}

.sidebar-toggle {
  position: absolute;
  right: -24px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 60px;
  background: var(--el-color-primary);
  border: 1px solid var(--el-border-color);
  border-left: none;
  border-radius: 0 4px 4px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: background-color 0.3s;
}

.sidebar-toggle:hover {
  background-color: var(--el-color-primary-light-3);
}

.sidebar-toggle .el-icon {
  transition: transform 0.3s;
}

.sidebar-toggle .rotated {
  transform: rotate(180deg);
}

@media (max-width: 768px) {
  .chat-sidebar {
    width: 100%;
    max-width: 300px;
  }
}
</style> 